home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows 95 / Programming Windows 95.iso / code / CHAP15 / PRINT1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-01  |  1.2 KB  |  46 lines

  1. /*---------------------------------------
  2.    PRINT1.C -- Bare Bones Printing
  3.                (c) Charles Petzold, 1996
  4.   ---------------------------------------*/
  5.  
  6. #include <windows.h>
  7.  
  8. HDC  GetPrinterDC (void) ;              // in PRINT.C
  9. void PageGDICalls (HDC, int, int) ;
  10.  
  11. HINSTANCE hInst ;
  12. char      szAppName[] = "Print1" ;
  13. char      szCaption[] = "Print Program 1" ;
  14.  
  15. BOOL PrintMyPage (HWND hwnd)
  16.      {
  17.      static DOCINFO di     = { sizeof (DOCINFO), "Print1: Printing", NULL } ;
  18.      BOOL           bError = FALSE ;
  19.      HDC            hdcPrn ;
  20.      int            xPage, yPage ;
  21.  
  22.      if (NULL == (hdcPrn = GetPrinterDC ()))
  23.           return TRUE ;
  24.  
  25.      xPage = GetDeviceCaps (hdcPrn, HORZRES) ;
  26.      yPage = GetDeviceCaps (hdcPrn, VERTRES) ;
  27.  
  28.      if (StartDoc (hdcPrn, &di) > 0)
  29.           {
  30.           if (StartPage (hdcPrn) > 0)
  31.                {
  32.                PageGDICalls (hdcPrn, xPage, yPage) ;
  33.  
  34.                if (EndPage (hdcPrn) > 0)
  35.                     EndDoc (hdcPrn) ;
  36.                else
  37.                     bError = TRUE ;
  38.                }
  39.           }
  40.      else
  41.           bError = TRUE ;
  42.  
  43.      DeleteDC (hdcPrn) ;
  44.      return bError ;
  45.      }
  46.